package com.lonely.order.enums;

import com.lonely.common.exception.BusinessException;
import lombok.Getter;

/**
 * @author: 黄志标
 * @date: 2025/6/24 14:59
 * @description: 分单相关枚举
 */
public class OrderSplitEnum {


    /**
     * 分单类型枚举
     */
    @Getter
    public enum SplitTypeEnum {

        /**
         * 车间
         */
        WORKSHOP(1),

        /**
         * 尾部
         */
        TAIL(2);

        /**
         * 分单类型
         */
        private final int type;

        SplitTypeEnum(int type) {
            this.type = type;
        }

        /**
         * 根据类型获取枚举
         *
         * @param type
         * @return
         */
        public static SplitTypeEnum getInstance(int type) {
            for (SplitTypeEnum value : SplitTypeEnum.values()) {
                if (value.getType() == type) {
                    return value;
                }
            }
            throw new BusinessException("分单类型不存在");
        }

    }
}